package com.xframe.xdal.core.serialize.lang;

import com.xframe.xdal.core.util.StringUtil;

import java.util.HashMap;
import java.util.Map;

public class LanguageItem {

    private Map<String,ModelLanguageItem> modelLanguageItemMap = new HashMap<>();


    public void add(String modelCode,ModelLanguageItem modelLanguageItem){
        modelLanguageItemMap.put(modelCode,modelLanguageItem);
    }

    public String getModelName(String modelCode){
        ModelLanguageItem modelLanguageItem = modelLanguageItemMap.get(modelCode);
        if(modelLanguageItem == null){
            return StringUtil.EMPTY;
        }
        return modelLanguageItem.getModelName();
    }

    public String getAttrText(String modelCode,String attrName,String headText){
        ModelLanguageItem modelLanguageItem = modelLanguageItemMap.get(modelCode);
        if(modelLanguageItem == null){
            return headText;
        }
        AttrItem attrItem = modelLanguageItem.getModelAttrMap().get(attrName);
        if(attrItem == null){
            return headText;
        }
        return attrItem.getDesc();
    }

}
